package com.hc.kt

fun main(){
    var s = Son(age = 10,name = "zhangsan")
    s.read()
    SingleObject.f1()
    var f = object :Father("lisi",20){}
    println(f)
    Son.sayHello()
}
open class Father(var name:String,var age:Int){
    open fun read(){
        println("Father read")
    }

    override fun toString(): String {
        return "Father(name='$name', age=$age)"
    }

}
class Son(name:String,age:Int):Father(name, age){
    init {
        println("i am son init")
    }
    operator fun component1() = name
    companion object{
        fun sayHello(){
            println("Son Hello")
        }
    }
    constructor(name: String):this(name,10){
        println("i am son second constructor")
    }
}
object SingleObject{
    fun f1(){
        println("so f1()")
    }
}
data class dataclass(var name:String){
    operator fun plus(p:dataclass):dataclass{
        return dataclass(name+p.name)
    }
}
enum class enumclass{
    UP,
    DOWN,
    LEFT,
    RIGHT
}

